package org.luxor.common.netty.constant;

import org.luxor.commons.core.web.IRestStatus;

/**
 * 异常状态码定义
 * <p>
 * 建议规格：{1位,范围分级}+{2位,项目编码}+{2位,模块编码}+{3位,错误码} = 8位固定码
 * <p>
 * 含义说明
 * 1.范围分级：固定1位，代表引起异常原因的所属边界范围 (1代表系统自身缺陷; 2代表调用方不合规操作; 3代表外部支撑端故障)
 * 2.项目编码：固定2位，项目分类编码(固定01,代表luxor-framework技术框架)
 * 3.模块编码：固定2位，项目模块编码(固定11,代表luxor-common-netty组件)
 * 4.错误编码：固定3位，自定义异常码
 *
 * @author XinmingYan @date 2019/9/16
 */
public enum NettyReasonCode implements IRestStatus {
    SUCCESS(0, "执行成功"),
    ERROR(10111000, "执行失败"),
    CONNECTION_CLIENT_ID_NOT_VALID(10111001, "连接失败,客户端ID无效或未授权"),
    CONNECTION_BAD_USERNAME_OR_PASSWORD(10111002, "连接失败,账号或密码,不允许为空"),
    CONNECTION_INVALID_PASSWORD(10111003, "连接失败,密码不正确"),

    DISCONNECT(10111004, "连接已断开，请重新建立连接"),
    INVALID_MESSAGE(20111001,"解码异常,无效报文"),
    UNKNOWN(10111999, "未知异常");

    private final Integer code;
    private final String message;

    NettyReasonCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String message() {
        return message;
    }

}
